package com.wdy.po;

import java.io.Serializable;
import java.util.Date;

import com.wdy.util.BasicUtil;

@SuppressWarnings( { "unchecked", "serial" })
public class Charge implements Comparable, Serializable {

	private Integer cid;
	private Date cdate;
	private String item;
	private Float total;
	private Float payed;
	private Float owe;
	private String payWay;
	private Date payDate;
	private String transactor;
	private String note;
	private Tenement tenement;

	public Charge() {
		super();
	}

	public Charge(Integer cid, Date cdate, String item, Float total,
			Float payed, Float owe, String payWay, Date payDate,
			String transactor, String note, Tenement tenement) {
		super();
		this.cid = cid;
		this.cdate = cdate;
		this.item = item;
		this.total = total;
		this.payed = payed;
		this.owe = owe;
		this.payWay = payWay;
		this.payDate = payDate;
		this.transactor = transactor;
		this.note = note;
		this.tenement = tenement;
	}

	public Integer getCid() {
		return cid;
	}

	public void setCid(Integer cid) {
		this.cid = cid;
	}

	public Date getCdate() {
		return cdate;
	}

	public void setCdate(Date cdate) {
		this.cdate = cdate;
	}

	public String getItem() {
		return item;
	}

	public void setItem(String item) {
		this.item = item;
	}

	public Float getTotal() {
		return total;
	}

	public void setTotal(Float total) {
		this.total = total;
	}

	public Float getPayed() {
		return payed;
	}

	public void setPayed(Float payed) {
		this.payed = payed;
	}

	public Float getOwe() {
		return owe;
	}

	public void setOwe(Float owe) {
		this.owe = owe;
	}

	public String getPayWay() {
		return payWay;
	}

	public void setPayWay(String payWay) {
		this.payWay = payWay;
	}

	public Date getPayDate() {
		return payDate;
	}

	public void setPayDate(Date payDate) {
		this.payDate = payDate;
	}

	public String getTransactor() {
		return transactor;
	}

	public void setTransactor(String transactor) {
		this.transactor = transactor;
	}

	public String getNote() {
		return note;
	}

	public void setNote(String note) {
		this.note = note;
	}

	public Tenement getTenement() {
		return tenement;
	}

	public void setTenement(Tenement tenement) {
		this.tenement = tenement;
	}

	/*
	 * @Override public boolean equals(Object o) { if(null == o) { return false;
	 * } if(o instanceof Charge){ Charge contrastCharge = (Charge)o; Integer
	 * contrastCid = contrastCharge.getCid(); Date contrastDate =
	 * contrastCharge.getDate(); if(this.cid.equals(contrastCid) &&
	 * this.date.equals(contrastDate)){ return true; } } return false; }
	 * 
	 * @Override public int hashCode() { return this.cid.hashCode() *
	 * this.date.hashCode(); }
	 */
	@Override
	public String toString() {
		String str = this.cdate.toString() + item;
		return str;
	}

	public int compareTo(Object o) {
		Charge contrastCharge = (Charge) o;
		Integer contrastCid = contrastCharge.getCid();
		int orignalId = this.cid.intValue();
		int contrastId = contrastCid.intValue();
		return BasicUtil.compare(orignalId, contrastId);
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((cid == null) ? 0 : cid.hashCode());
		result = prime * result + ((cdate == null) ? 0 : cdate.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (!(obj instanceof Charge))
			return false;
		final Charge other = (Charge) obj;
		if (cid == null) {
			if (other.cid != null)
				return false;
		} else if (!cid.equals(other.cid))
			return false;
		if (cdate == null) {
			if (other.cdate != null)
				return false;
		} else if (!cdate.equals(other.cdate))
			return false;
		return true;
	}
}
